/*
 * Class Brain.java
 * 9.06.2012
 * 
 * Class represents brain organ.
 */

package human;

/**
 * Class implements a model of human brain.
 * It has a number of characteristics (such as fatigue and oxygen level)
 * which changes according human activities.
 * Brain could be cause of death because it's vital organ.
 * 
 * @author Vasyl Khyzhniak
 * @version 1.0
 */
public class Brain extends Organ {
	private int fatigue;				//how much it tired
	private int oxygenation;			//oxygen level
	private int memory;					//ability to remember
	
	
	/**
	 * Brain Class Constructor
	 * Sets all live characteristics to newborn level which
	 * is equal to zero.
	 * Also defines brain as necessary for life organ 
	 * (isNecessaryForLife = true)
	 * @author Vasyl Khyzhniak
	 */
	public Brain() {
		this.health = 0;
		this.fatigue = 0;
		this.memory = 0;
		this.oxygenation = 0;
		this.isNecessaryForLife = true;
		this.upperLimit = 100;
		this.lowerLimit = -100;
	}
	
	/**
	 * Changes brain fatigue on value
	 * @param value Defines the change of brain fatigue
	 * @author Vasyl Khyzhniak
	 */
	public void changeFatigue(int value) {
		if (this.fatigue + value > this.upperLimit) {				//keeps value in limit [-100,100]
			this.fatigue = this.upperLimit;
		} else if (this.fatigue + value < this.lowerLimit) {
			this.fatigue = this.lowerLimit;
		} else {
			this.fatigue += value;
		}
	}
	
	/**
	 * Changes level of oxygenation on value
	 * @param value Defines the change of oxygenation
	 * @author Vasyl Khyzhniak
	 */
	public void changeOxygenation(int value) {		
		if (this.oxygenation + value > this.upperLimit) {		//keeps value in limit [-100,100]
			this.oxygenation = this.upperLimit;
		} else if (this.oxygenation + value < this.lowerLimit) {
			this.oxygenation = this.lowerLimit;
		} else {
			this.oxygenation += value;
		}		
	}
	
	/**
	 * Changes brain opportunity to remember information on value.
	 * @param value Defines the change of opportunity to remember
	 * @author Vasyl Khyzhniak
	 */
	public void changeMemory(int value) {
		if (this.memory + value > this.upperLimit ){				//keeps value in limit [-100,100]
			this.memory = this.upperLimit;
		} else if (this.memory + value < this.lowerLimit ) {
			this.memory = this.lowerLimit;
		} else {
			this.memory += value;
		}		
	}
	
	/**
	 * @return value of current brain fatigue
	 * @author Vasyl Khyzhniak
	 */
	public int getFatigue() {
		return this.fatigue;
	}
	
	/**
	 * @return value of current brain oxygenation
	 * @author Vasyl Khyzhniak
	 */
	public int getOxygenation() {
		return this.oxygenation;
	}
	
	/**
	 * @return value of brain opportunity to remember.
	 * @author Vasyl Khyzhniak
	 */
	public int getMemory() {
		return this.memory;
	}
}
